﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Manager;
using Model;
using ExtAspNet;
namespace HealthSystem
{
    public partial class Org_Edit : BasePage
    {
        HW_OrgManager manager = new HW_OrgManager();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                btnClose.OnClientClick = ActiveWindow.GetConfirmHidePostBackReference();
                string id = Request["id"].ToString();
                HW_Org org = manager.GetById(id);
                //bool exist = DistrictCache.CheckExist(CustomerProfile.DistrictId, school.DistrictCode);
                //if (exist)
                //{
                Bind(org);
                //}
            }
        }
        public void Bind(HW_Org org)
        {
            this.name.Text = org.OrgName;
            this.id.Text = org.OrgCode;
            this.Address.Text = org.hw_OrgDetail.Address;
            this.Email.Text = org.hw_OrgDetail.Email;
            this.MobilePhone.Text = org.hw_OrgDetail.MobilePhone;
            OfficePhone.Text = org.hw_OrgDetail.OfficePhone;
            this.LinkMan.Text = org.hw_OrgDetail.LinkMan;
            Fax.Text = org.hw_OrgDetail.Fax;
        }
        protected void Save_Click(object sender, EventArgs e)
        {
            string id = Request["id"].ToString();
            HW_Org org = manager.GetById(id);
            bool exist = DistrictCache.CheckExist(CustomerProfile.DistrictId, org.DistrictCode);
            if (exist)
            {
                org.OrgName = this.name.Text;
                org.hw_OrgDetail.Address = Address.Text;
                org.hw_OrgDetail.Email = Email.Text;
                org.hw_OrgDetail.Fax = Fax.Text;
                org.hw_OrgDetail.LinkMan =LinkMan.Text;
                org.hw_OrgDetail.MobilePhone = MobilePhone.Text;
                org.hw_OrgDetail.OfficePhone = OfficePhone.Text;
                manager.ModHW_Org(org);
                PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
            }
            else
            {
                Alert.Show("您没有权限修改该学校");
            }
        }
    }
}